package com.howcode.aqchat.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.howcode.aqchat.service.dao.mapper.IAQUserMapper;
import com.howcode.aqchat.service.dao.po.AqUser;
import com.howcode.aqchat.service.service.IAQUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @Author: ZhangWeinan
 * @Description:
 * @date 2024-04-27 12:42
 */
@Service
public class AQUserServiceImpl implements IAQUserService {
    @Resource
    private IAQUserMapper userMapper;
    @Override
    public AqUser getUserById(String userId) {
        return userMapper.selectById(userId);
    }


    @Override
    public AqUser getUserByEmail(String email) {
        LambdaQueryWrapper<AqUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AqUser::getUserEmail,email);

        return userMapper.selectOne(wrapper);
    }

    @Override
    public void saveUser(String userId, String userName, String userAvatar,String email,String pwd) {
        AqUser user = new AqUser();
        user.setUserId(userId);
        user.setUserName(userName);
        user.setUserAvatar(userAvatar);
        user.setUserEmail(email);
        user.setUserPwd(pwd);
        userMapper.insert(user);
    }
}
